//
// Model for traffic induced by worm.
//
// @author Michael Liljenstam, ISTS, Dartmouth College
//
// $Id: MeanRateEgressTrafficState.java,v 1.2 2003/03/02 20:47:57 mili Exp $

package SSF.App.Worm;


/**
 *  Worm induced traffic model.
 *  Contains information about scanning traffic induced by the worm.
 */
public class MeanRateWormTrafficState extends WormTrafficState {

    // state 
    /** Mean scan rate. (Outbound) */
    public float scanRate = 0F;

    public MeanRateWormTrafficState(AS _myAS) {
	super(_myAS);
    }
      
    /** 
     *  State update. 
     *  The mean outbound scan rate is set proportional to the number of 
     *  infected hosts in this AS. The scan rate is then updated for each 
     *  registered gateway (border) router. <br>
     *  Assumption: the simplifying assumption is made that the scans are 
     *  spread evenly over the (registered) border routers.
     */
    @Override
	public void update() {
	// proportional to #infected
	scanRate = 
	    ((MeanRateWormTraffic)MacroscopicModel.ref.wormTraffic).
	    meanScanRate * myAS.wormModel.i; 

	// calc scan rate per router
	int numRouters = myAS.borderRouterList.size();
	float ratePerR = scanRate / numRouters;

	// update registered routers
	myAS.updateBorderRouters(ratePerR);
    }
} // class WormTraffic


